{extend name="public:common_edit"/}
{block name="main"}
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title"><i class="fa fa-list"></i> {$title}</h3>
        </div>
        <div class="panel-body">
            <div class="navbar navbar-default">
                <form action="" id="search-form2" class="navbar-form form-inline" method="get" onsubmit="return false">
                </form>
            </div>
            <div id="ajax_return">
                <form method="post" enctype="multipart/form-data" target="_blank" id="form-order">
                    <div class="table-responsive">
                        <table class="table table-bordered table-hover">
                            <thead>
                            <tr>
                                <td>id</td>
                                <td>类型</td>
                                <td>名称</td>
                                <td>价值</td>
                                <td>中奖概率</td>
                                <td>赠送锤子概率</td>
                                <td>铜宝箱概率</td>
                                <td>银宝箱概率</td>
                                <td>金宝箱概率</td>
                                <td>备注</td>
                                <td>操作</td>
                            </tr>
                            </thead>
                            <tbody>
                            <!-- 列表循环开始 -->
                            {volist name="rows" id="row" key="key"}
                            <tr>
                                <td>{$row.id}</td>
                                <td style="max-width: 160px">

                                    {if $row.type == 1} 礼物 {else /} 道具卡 {/if}
                                </td>

                                <td style="width: 15%">

                                    {if $row.type == 1}
                                    <input readonly type="text" name="name[]" class="form-control" value="{$row.name}">
                                    {else /}
                                    <input type="text" name="name[]" class="form-control" value="{$row.name}">
                                    {/if}

                                </td>
                                <td style="width: 8%">
                                    {if $row.type == 1}
                                        <input readonly type="number" name="price[]" class="form-control" value="{$row.price}">
                                    {else /}
                                        <input type="number" name="price[]" class="form-control" value="{$row.price}">
                                    {/if}
                                </td>
                                <td style="width: 8%;">
                                    <input type="number" name="chance[]" class="form-control" value="{$row.chance}">
                                    <input type="hidden" name="id[]" value="{$row.id}">
                                </td>
                                <td style="width: 8%;">
                                    <input type="number" name="giveChance[]" class="form-control" value="{$row.giveChance}">
                                </td>
                                <td style="width: 8%;">
                                    <input type="number" name="box4[]" class="form-control" value="{$row.box4}">
                                </td>
                                <td style="width: 8%;">
                                    <input type="number" name="box5[]" class="form-control" value="{$row.box5}">
                                </td>
                                <td style="width: 8%;">
                                    <input type="number" name="box6[]" class="form-control" value="{$row.box6}">
                                </td>
                                <td>
                                    <input type="text" name="remark[]" class="form-control" value="{$row.remark}">
                                </td>
                                <td>
                                    {if $row.type == 1}
                                    <span class="btn btn-danger check_del" data-message="" data-url="{:url('draw_del',['id'=>$row.id])}">删除</span>
                                    {/if}
                                </td>
                            </tr>
                            {/volist}


                            <tr>
                                <td>    </td>
                                <td >


                                </td>

                                <td >


                                </td>
                                <td >

                                </td>
                                <td style="width: 8%;">
                                    <input data-field="chance" class="btn btn-primary submit1" type="button" value="保存">
                                </td>
                                <td style="width: 8%;">
                                    <input data-field="giveChance" class="btn btn-primary submit1" type="button" value="保存">
                                </td>
                                <td style="width: 8%;">
                                    <input data-field="box4" class="btn btn-primary submit1" type="button" value="保存">
                                </td>
                                <td style="width: 8%;">
                                    <input data-field="box5" class="btn btn-primary submit1" type="button" value="保存">
                                </td>
                                <td style="width: 8%;">
                                    <input data-field="box6" class="btn btn-primary submit1" type="button" value="保存">
                                </td>
                                <td>

                                </td>
                                <td>

                                </td>
                            </tr>



                            <!-- 列表循环结束 -->
                            </tbody>
                        </table>
                    </div>
                    <!--<div class="pull-right">-->
                        <!--<label class="control-label col-sm-2"></label>-->

                        <!--<input class="btn btn-primary submit" type="submit" value="保存">-->
                    <!--</div>-->
                </form>
            </div>

        </div>
    </div>
<div class="modal fade" id="bjy-add" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> &times;</button>
                <h4 class="modal-title" id="myModalLabe"> 添加说明</h4></div>
            <div class="modal-body">
                <form id="bjy-form" class="form-inline" action="{:url('rule/ex_add')}" method="post">
                    <table class="table table-striped table-bordered table-hover table-condensed">
                        <tr>
                            <th width="20%">标记字段：</th>
                            <td><input class="form-control" type="text" name="field"></td>
                        </tr>
                        <tr>
                            <th>介绍：</th>
                            <td><input class="form-control" type="text" name="msg"></td>
                        </tr>
                        <tr>
                            <th>内容：</th>
                            <td><input class="form-control" type="text" name="content">
                            </td>
                        </tr>
                        <tr>
                            <th></th>
                            <td><input class="btn btn-success submit" type="submit" value="保存"></td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
    </div>
</div>
{/block}

{block name="js"}
<script>

    $('.submit1').click(function () {
        var btn = $(this);
        btn.attr('disabled', 'disabled');
        var load=layer.load(1, {
            shade: [0.3,'#999999'] //0.1透明度的白色背景
        });

        var id = btn.parents('form').attr('id');
        var formData =  new FormData($('#'+id)[0]);


        var url = "{:url('')}";

        var field = $(this).data('field');

        formData.append('field',field);

        $.ajax({
            url: url,
            type: 'POST',
            data: formData,
            async: false,
            cache: false,
            contentType: false,
            processData: false,
            success: function (result) {
                if (result.code == 1) {
                    successRedirect(result.msg, result.url, 1);
                }
                else if (result.code == 3){
                    topRedirect(result.msg, result.data, 1);
                }
                else {
                    zcAlert(result.msg,0);
                    layer.closeAll("loading");
                    btn.attr('disabled', false);
                }
            },
            error: function () {
                layer.msg('请求失败,网络连接超时', {icon: 5, time: 2000});
                layer.closeAll("loading");
                btn.attr('disabled', false);
            }
        });
        return false;
    });









    function add(obj) {

        $("input[name='msg']").val('');
        $("input[name='content']").val('');
        $('#bjy-add').modal('show');
    }
    $(function () {
        // 添加子菜单


        var type   = "{$Think.get.type}";
        if(type != ''){
            $('#type'+type).attr('selected',true)
        }

        var status   = "{$Think.get.status}";
        if(status != ''){
            $('#status'+status).attr('selected',true)
        }
    })

</script>



{/block}



